package cs4280.ass2.admin.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;

import cs4280.ass2.persistence.MovieDao;

public class MovieDeleteAction extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String id = req.getParameter("id");
		if (StringUtils.isNotBlank(id)) {
			MovieDao.getInstance().deleteMovie(NumberUtils.toLong(id, 0));
		}
		resp.sendRedirect("/cinema/admin/movie/list.do");
	}
}
